package org.ilc.socketserver;

import org.ilc.push.ISession;
import org.ilc.util.ValidateUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * @author malongbo
 */
public class Session implements ISession {
    private Map<String,Object> attributes=null;

    public Session(){ }

    @Override
    public void setAttribute(String key, Object value) {
        if(!ValidateUtil.validateStr (key) || null == value){
            return;
        }

        if(null == attributes){
            attributes = new HashMap<String,Object> (0);
        }
        attributes.put(key, value);
    }

    @Override
    public Object getAttribute(String key) {
        return null == this.attributes ? null : this.attributes.get(key);
    }
}
